//
//  DCAut ContactsInfoCell.m
//  Demo
//
//  Created by zhaolin on 2023/1/13.
//

#import "DCAuthContactsInfoCell.h"


@interface DCAuthContactsInfoCell ()

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *relationLabel;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UILabel *mobileLabel;

@end
@implementation DCAuthContactsInfoCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configureUI];
    }
    return self;
}

- (void)setDataWithContactName:(NSString *)contactName contactPhone:(NSString *)contactPhone realtion:(NSString *)relation {
    _relationLabel.text = relation;
    _nameLabel.text = contactName;
    _mobileLabel.text = contactPhone;
}

- (void)configureUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor colorWithString:@"#FFFFFF"];
    _titleLabel = [UILabel new];
    _titleLabel.text = @"First contact person";
    _titleLabel.textColor = [UIColor colorWithString:@"#1C221B"];
    _titleLabel.font = DCFont_PF_Semibold(13);
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(32);
        make.top.mas_equalTo(15);
    }];
    
    UIView *colorView = [UIView new];
    colorView.backgroundColor = [UIColor colorWithString:@"#F7F7F7"];
    colorView.layer.cornerRadius = 8;
    colorView.layer.masksToBounds = YES;
    [self.contentView addSubview:colorView];
    [colorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(17);
        make.right.mas_equalTo(-17);
        make.top.mas_equalTo(_titleLabel.mas_bottom).mas_offset(10);
        make.bottom.mas_equalTo(-15);
    }];
    
    UILabel *nameLabel = [UILabel new];
    _nameLabel = nameLabel;
    nameLabel.textColor = [UIColor colorWithString:@"#1C221B"];
    nameLabel.font = DCFont_PF_Regular(13);
    nameLabel.text =  @"Name:John";
    [colorView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(33);
        make.centerY.mas_equalTo(colorView.mas_centerY);
    }];
    
    UIView *topSpaceView = [UIView new];
    topSpaceView.backgroundColor = [UIColor clearColor];
    [colorView addSubview:topSpaceView];
    [topSpaceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(nameLabel.mas_top);
    }];
    
    UILabel *relationLabel = [UILabel new];
    _relationLabel = relationLabel;
    relationLabel.textColor = [UIColor colorWithString:@"#1C221B"];
    relationLabel.font = DCFont_PF_Regular(13);
    relationLabel.text =  @"Relation:father";
    [topSpaceView addSubview:relationLabel];
    [relationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.centerY.mas_equalTo(topSpaceView);
    }];
    
    UIButton *reSelectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    reSelectBtn.backgroundColor = [UIColor colorWithString:@"#F0FFCE"];
    reSelectBtn.layer.cornerRadius = 20;
    reSelectBtn.layer.masksToBounds = YES;
    [reSelectBtn setTitle:@"RE-SELECT" forState:UIControlStateNormal];
    [reSelectBtn setTitleColor:[UIColor colorWithString:@"#1C221B"] forState:UIControlStateNormal];
    reSelectBtn.titleLabel.font = DCFont_PF_Semibold(12);
    [reSelectBtn addTarget:self action:@selector(reSelectAction:) forControlEvents:UIControlEventTouchUpInside];
    [topSpaceView addSubview:reSelectBtn];
    [reSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-21);
        make.centerY.mas_equalTo(relationLabel);
        make.width.mas_equalTo(104);
        make.height.mas_equalTo(40);
    }];
    
    UIView *bottomSpaceView = [UIView new];
    bottomSpaceView.backgroundColor = [UIColor clearColor];
    [colorView addSubview:bottomSpaceView];
    [bottomSpaceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(nameLabel.mas_bottom);
    }];
    
    UILabel *mobileLabel = [UILabel new];
    _mobileLabel = mobileLabel;
    mobileLabel.textColor = [UIColor colorWithString:@"#1C221B"];
    mobileLabel.font = DCFont_PF_Regular(13);
    mobileLabel.text =  @"Mobile:13824586377";
    [bottomSpaceView addSubview:mobileLabel];
    [mobileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.centerY.mas_equalTo(bottomSpaceView);
    }];
    
}

- (void)reSelectAction:(UIButton *)sender {
    if(self.delegate && [self.delegate respondsToSelector:@selector(authContactsInfoCellReselect:)]) {
        [self.delegate authContactsInfoCellReselect:self.indexPath];
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
